/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;
import java.sql.*;

/**
 *
 * @author XuanHung
 */
public class Datacontact {
    private Connection m_conn;
    private final String m_strURL= "jdbc:mysql://localhost:3306/quanlynhanvien";
    private final String m_strUserName = "root";
    private final String m_strPassword = "";

    public Connection getM_conn() {
        return m_conn;
    }

    public void setM_conn(Connection m_conn) {
        this.m_conn = m_conn;
    }

    public Datacontact(Connection m_conn) {
        this.m_conn = m_conn;
    }

    
    

    public Datacontact() {
    }
    
    public boolean Connect() throws ClassNotFoundException, InstantiationException, IllegalAccessException, Exception{
        boolean bEqual = false;
        try{
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            this.setM_conn(DriverManager.getConnection(m_strURL, m_strUserName, m_strPassword));
            bEqual =  true; // da ket noi dc toi csdl
        }
        catch(ClassNotFoundException | InstantiationException | IllegalAccessException ex){
            throw new Exception(ex.toString());
        }
        
        return bEqual;
        
    }
    
    public void close() throws SQLException{
        this.m_conn.close();
    }
    //public Statement 
}
